<template>
	<scroll ref="mescrollRef" @init="mescrollInit" :down="downOption"  @down="downCallback" :up="upOption" @up="upCallback" @emptyclick="emptyClick">
		<stop isBack>
			<view slot="content">保养单</view>
		</stop>
			<!-- <view class="bcf padlr3 padtb2 bdtso mart3 flrc">
				<view class="flex1">
					<search class="fs8 tac" placeholder=" 单号 \ 物资名称 \ 编码 \ 型号"  v-model="search" @search="doSearch()"></search>
				</view>
				<view class="marl3">
					<view class="cu-btn round bg-green" @tap="goto('/pages/machi_maintain/maintain_order_form')">
						新建
						<ripple></ripple>
					</view>
				</view>
			</view> -->
			<view class="padlr3">
				<view class="bcf pos-r mart3 pad2 round2 shadow ofh" @tap="goto('/pages/machi_maintain/maintain_info?id=' + order.id)"
				v-for="order,index in data" :key="order.id">
					<view class="pos-r padr2 ofh"v-if="isbool(order)">
						<check-order :item="order"></check-order>
						<!-- <view class="bc13 pad2">
							<machine-item :item="order.machine" ></machine-item>
						</view> -->
						<ripple></ripple>
					</view>
				</view>
			</view>
		<loading :loading="myIsLoading"></loading>
	</scroll>
</template>

<script>
	import MescrollMixin from "@/components/mescroll-uni/mescroll-mixins.js";
	import List from '../../../assets/js/list.js'
	
	import checkOrder from '../../../templete/machine/machine_plan_maintain_order_item.vue'
	import machinePicker from '../../../templete/machine/machine_picker.vue'
	import machineItem from '../../../templete/machine/machine_item.vue'
	export default {
		mixins:[MescrollMixin],
		components:{checkOrder,machinePicker,machineItem},
		data() {
			let list = new List()
			return {
				machine:'',
				list,
				where:{
					eq:{
						machine:'/api_/machines/',
						emergency:'',
						level:'',
					}
				},
				search:"",
				data:[]
			}
		},
		methods: {
			reload(){
				this.showLoading()
				this.data=[]
				this.list.setData({_order:{id:"DESC"},_where:this.where,_search:this.search}).reload()
			},
			doSearch(){
				this.showLoading()
				this.data=[]
				this.list.setData({_order:{id:"DESC"},_where:this.where,_search:this.search}).reload()
			},
			startCheck(){
				if(this.isbool(this.machine)){
					this.showLoading()
					this.$api.get('/api/start/machineMaintainOrders',{id:this.$com.iriId(this.machine)},res=>{
						this.clearLoading()
						this.log(res)
						if(res.s == 1){
							setTimeout(()=>{this.goto('/pages/machi_maintain/maintain_do?id=' + res.d.id)},500)
						}else{
							this.$com.showToast(res.i)
						}
					})
				}else{
					this.$com.showToast('未选择设备')
				}
			}
		},
		onLoad(Option) {
			this.id = Option.id
		},
		mounted() {
			this.where.eq.machine = this.id
			this.list.initMescroll(this).setUrl('/api/machineMaintainOrders').setData({
				_order:{id:"DESC"},
				_where:this.where,
				_search:this.search,
			}).setCbFunc(res=>{
				this.data = res
				this.clearLoading()
			}).reload()
		},
		onShow() {
			this.log("onshow")
			this.showLoading()
			this.list.reload()
			// this.myCurTab = 1
		},
		watch:{
			machine(val){
				this.log(val)
			}
		}
	}
</script>

<style>

</style>
